package com.fat.spzx.manager.controller;

import com.fat.spzx.manager.service.FileUploadService;
import com.fat.spzx.model.vo.common.Result;
import com.fat.spzx.model.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传
 * @author : fat
 */
@Tag(name = "文件上传模块")
@RestController
@RequestMapping(value = "/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 文件上传
     * return 返回文件访问路径
     */
    @Operation(summary = "文件上传")
    @PostMapping(value = "/fileUpload")
    public Result fileUpload(MultipartFile file){
        String url = fileUploadService.upload(file);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }

}
